package weatherapp.parser;

import org.json.*;

public class OpenWeatherMapParser extends WeatherParser {
    public WeatherData parse(String json) {
        JSONObject obj = new JSONObject(json);
        double temp = obj.getJSONObject("main").getDouble("temp");
        int humidity = obj.getJSONObject("main").getInt("humidity");
        String icon = obj.getJSONArray("weather").getJSONObject(0).getString("icon");
        return new WeatherData(temp, humidity, icon);
    }
}
